#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int n, m;
int a[N];
int ch[2][N << 5], val[N << 5], ndn, rt[N];

int nd(int t = 0) { int x = ++ndn; val[x] = t, ch[0][x] = ch[1][x] = 0; return x; }
int copy(int t) { int x = ++ndn; val[x] = val[t], ch[0][x] = ch[0][t], ch[1][x] = ch[1][t]; return x; }

void build(int &x, int l = 1, int r = n) {
	if(!x) x = nd(); if(l == r) return val[x] = a[l], void(); int mid = l + r >> 1;
	build(ch[0][x], l, mid), build(ch[1][x], mid + 1, r); 
}

void upd(int &x, int pos, int v, int l = 1, int r = n) {
	x = copy(x); if(l == r) return val[x] = v, void(); int mid = l + r >> 1;
	if(pos <= mid) upd(ch[0][x], pos, v, l, mid); else upd(ch[1][x], pos, v, mid + 1, r);
}

int query(int x, int pos, int l = 1, int r = n) {
	if(l == r) return val[x]; int mid = l + r >> 1;
	if(pos <= mid) return query(ch[0][x], pos, l, mid); else return query(ch[1][x], pos, mid + 1, r);
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in;
	rep(i, 1, n) a[i] = in;
	build(rt[0]);
	rep(i, 1, m) {
		int v = in, op = in, pos = in;
		rt[i] = rt[v];
		if(op == 1) {
			upd(rt[i], pos, in);
		} else {
			printf("%d\n", query(rt[i], pos));
		}
	}
	return 0;
}
